<html>
<head><#include "common/common.html"/>
<#include "common/css_js.html"/> <#include "common/fupage.html" />
<#include "common/artdialog.html"/>
<script type="text/javascript">
	$(document).ready(function() {
		var backUrl = base + "/privilege/";
		$("#add").bind("click", function() {
			var pass =  $("#editForm").validationEngine("validate");
			if(!pass){
				return;
			}
			var name = $("#name").val();
			var enname = $("#enname").val();
			var url = $("#url").val();
			var pacl = $("#pacl").val();
			var ismenu = $("#ismenu").val();
			var sort = $("#sort").val();
			var acl = $("#acl").val();
			post(base + "/privilege/doupdate.js?v=${bv}on", {
				"name" : name,
				"enname" : enname,
				"url" : url,
				"pacl" : pacl,
				"ismenu" : ismenu,
				"sort" : sort,
				"acl" : acl
			}, function(data) {
				if (data.code == 1) {
					var d = dialog({
						title : defaultAlertTitle,
						content : '更新权限成功',
						cancel : false,
						ok : function() {
							load(backUrl);
						}
					});
					d.show();
				}
			});
		});

		cancelBind(backUrl);
	});
</script>
</head>
<body>
	<div >
		<form id="editForm" class="validationEngine">
			<table>
				<tr>
					<td>中文名:</td>
					<td><input type="text" name="name" id="name" maxlength="20" class="validate[required,custom[chinese]]"
						value="${privilege.name}"></input></td>
				</tr>
				<tr>
					<td>英文名:</td>
					<td><input type="text" name="enname" id="enname" maxlength="20" class="validate[required,custom[onlyLetterSp]]"
						value="${privilege.enname}"></input></td>
				</tr>
				<tr>
					<td>请求链接:</td>
					<td><input type="text" name="url" id="url" class="validate[required,custom[url]]"
						value="${privilege.url}"></input></td>
				</tr>
				<tr>
					<td>上级权限:</td>
					<td><select name="pacl" id="pacl">
							<option value="-1"<#if
								privilege.pacl==-1>selected="selected"</#if> >顶级</option> <#list
							privilegeList as item>
							<option value="${item.acl}"<#if
								item.acl==privilege.pacl>selected="selected"</#if>
								>${item.name}</option> </#list>
					</select></td>
				</tr>
				<tr>
					<td>是否为菜单:</td>
					<td><select name="ismenu" id="ismenu">
							<option value="1"<#if
								privilege.ismenu==1>selected="selected"</#if>>是</option>
							<option value="0"<#if
								privilege.ismenu==0>selected="selected"</#if>>否</option>
					</select></td>
				</tr>
				<tr>
					<td>排序:</td>
					<td><#include "/common/sort.html"/></td>
				</tr><tr>
					<td><#include "common/form_submit_button.html"/></td>
				</tr>
				<input type="hidden" name="acl" id="acl" value="${privilege.acl}" />
			</table>
		</form>
<script type="text/javascript">
		var sort = "${privilege.sort}";
		if (sort != null && sort != "") {
			$("#sort").val(sort);
		}
</script>
</body>
</html>